#include "Observer.h"

Observer::Observer(void)
{
}


Observer::Observer(Vector4D position_, Vector4D destination_, double apertureAngle_){
	position = position_;
	apertureAngle = apertureAngle_;

	//Calcul de la matrice toRepereGlobal
	Vector4D od(position, destination_);
	od.normalize();
	//std::cout << "od: " << od->toString() << std::endl;

	Vector4D vup(0, 1, 0.0000001, 0);
	vup.normalize();
	//std::cout << "vup: " << vup->toString() << std::endl;

	Vector4D w = Vector4D::crossProduct(od, vup);
	w.normalize();
	//std::cout << "w: " << w->toString() << std::endl;

	vup = Vector4D::crossProduct(od, w);
	vup.normalize();
	//std::cout << "vup: " << vup->toString() << std::endl;

	toRepereGlobal = new Matrix4D(w, vup, od, destination_);
}

Vector4D* Observer::changeToRepereGlobal(Vector4D v){
	return Matrix4D::product(*toRepereGlobal, v);
}

Observer::~Observer(void)
{
	//delete toRepereGlobal;
}